/**

 Resources about B+ Trees

 - http://en.wikipedia.org/wiki/B%2B_tree

*/

#include <stdio.h>
#include <stdlib.h>
// define NULL pointer http://c-faq.com/index.html
#define NULL ((char *)0)

// it might be a good reason to have b+ tree so it can be used to represent files
// structures
typedef struct tree_data {
  int value;
  //file file  - tree_data_file
} tree_data;

//
typedef struct tree_node {
  void **ptrs;
  int *keys_ptr;
  struct tree_node *parent_ptr;
  int is_tree_leaf;// 1 yes, 0 no
  int key_numbers;
  struct tree_node *next_ptr; // to have fast iterations through linked list or queue
} tree_node;

/* tree create operations */

// create a new data link record withing a tree, value can be different
tree_data *create_tree_data(int value);
// create a new tree node, pointer to tree_node
tree_node *create_tree_node(int value);
// create a new tree leaf
tree_node *create_tree_leaf(int value);

/* tree insert operations */

// 
tree_node *insert_into_leaf(int key, tree_node *tree_leaf_ptr, tree_data *tree_data_ptr);

//
tree_node *insert_node(int key, tree_node *root_ptr, tree_node *parent, 
			int left_index,  tree_node *right_ptr);
//
tree_node *split_insert_node( int key, tree_node *root_ptr, tree_node *parent_ptr, int left_index, 
				   tree_node *right_ptr);
//
tree_node *insert_into_parent(int key, tree_node *root_ptr, tree_node *left_ptr, tree_node *right_ptr);
//
tree_node *insert_into_root(int key, tree_node *right_ptr, tree_node *left_ptr);
//
tree_node *create_tree(int key,  tree_data *ptr);



